import { baseUrl } from "./config.js";
import Axios from "axios";

Axios.defaults.baseURL = baseUrl;


export let getProcessOpinions = (safetySceneId) => {
    return (
        Axios.post("weChatSystem/getProcessOpinions", {
            safetySceneId: safetySceneId
        })
    );
}

export let addProcessOpinions = (weChatIdForSendMsg, safetySceneId, opinions) => {
    return (
        Axios.post("weChatSystem/addProcessOpinions", {
            weChatIdForSendMsg: weChatIdForSendMsg,
            safetySceneId: safetySceneId,
            opinions: opinions
        })
    );
}

export let getSignature = (url) => {
    return (
        Axios.get("weChatSystem/getSignature", {
            params: {
                url: url
            }
        })
    );
};

export let getInspectItem = (url) => {
    return (
        Axios.get("weChatSystem/getInspectItem", {
            params: {
                url: url
            }
        })
    );
};

export let getSafetySceneListForMessagePush = (id, status) => {
    return (
        Axios.post("weChatSystem/getSafetySceneListForMessagePush", {
            id: id,
            status: status
        })
    );
}

export let updateSafetySceneStatus = (id) => {
    return (
        Axios.post("weChatSystem/updateSafetySceneStatus", {
            safetySceneId: id,
        })
    );
}

export let getWeChatPushUserBySafetySceneId = (id) => {
    return (
        Axios.post("weChatSystem/getWeChatPushUserBySafetySceneId", {
            safetySceneId: id,
        })
    );
}

export let sendMessage = (touser, safetySceneId, realName, time, type) => {
    return (
        Axios.post("weChatSystem/sendMessage", {
            template: 1,
            touser,
            // touser: "oq0rl1H9-ClV3vUpUubtUQmE12wA",
            safetySceneId,
            data: {
                first: {
                    value: '【安全现场隐患】'
                },
                keyword1: {
                    value: realName
                },
                keyword2: {
                    value: time
                },
                keyword3: {
                    value: `${realName}在${time}发现的${type}类型隐患需由您处理`
                },
            }
        })
    );
}